<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Mailer {
  var $mail;
  public function __construct(){
    require('PHPMailer/class.phpmailer.php');
    require('PHPMailer/class.smtp.php');

    $this->mail = new PHPMailer(true);
    $this->mail->IsSMTP(); 
    $this->mail->CharSet       ="utf-8";      // 一定要設定 CharSet 才能正確處理中文
    $this->mail->SMTPDebug     =1;            // enables SMTP debug information
    $this->mail->SMTPAuth      = true;        // enable SMTP authentication
    // $this->mail->SMTPSecure = "ssl";       // sets the prefix to the servier
    $this->mail->Host          = "smtp.qq.com"; // sets qq as the SMTP server
    $this->mail->Port          = 25;          // set the SMTP port for the qq server
    $this->mail->Username      = "1500279497@qq.com";// qq username
    $this->mail->Password      = "qzm3931033"; // qq password
    $this->mail->AddReplyTo('1500279497@qq.com', 'solgh_to');
    $this->mail->SetFrom('1500279497@qq.com', 'solgh_from');
  }

  public function sendmail(){
    try{
        $this->mail->AddAddress('546079089@qq.com', 'solgh');
        $this->mail->Subject= '測試/test';
        $this->mail->Body= '測試內容/content';
        $this->mail->Send();
            echo "Message Sent OK</p>\n";
    } catch (phpmailerException $e) {
        echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
        echo $e->getMessage(); //Boring error messages from anything else!
    }
  }
}
?>